package com.zhangtong.excel.entity;

import java.math.BigDecimal;
import java.util.Map;
import java.util.TreeMap;

public class WorktimeData {
    protected String dimensionValue;
    protected BigDecimal totalWorktime;
    protected TreeMap<String, BigDecimal> statistics;

    public WorktimeData(String dimensionValue) {
        this.dimensionValue = dimensionValue;
        statistics = new TreeMap<>();
        totalWorktime = BigDecimal.ZERO;
    }

    public void addWorktime(String key, BigDecimal worktime) {
        if (!statistics.containsKey(key)) {
            statistics.put(key, BigDecimal.ZERO);
        }
        BigDecimal newVal = worktime.add(statistics.get(key));
        statistics.put(key, newVal);
        totalWorktime = totalWorktime.add(worktime);
    }

    public Map<String, BigDecimal> getStatisticsData() {
        return new TreeMap<>(statistics);
    }

    public BigDecimal getTotalWorktime() {
        return totalWorktime;
    }

    public String getDimensionValue() {
        return dimensionValue;
    }
}
